<?php 
session_start();
?>
	
<?php 
if(!isset($_SESSION["username"])) 
   { 
   echo "Bitte erst <a href=\"index.html\">einloggen</a>"; 
   exit; 
   } 
?> 
	
	
	

<html>

<head>


										
<title>Timetable</title>
<script type="text/javascript" src="jquery-ui-1.8.18.custom/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.18.custom/js/jquery-ui-1.8.18.custom.min.js"></script>





<style type="text/css">

.timetable {		
   position:absolute;
   left:0px;
   top:30px;
   z-index:1;
   border-color:black;
   border-width:10px;
   -moz-border-radius:10px;
   -khtml-border-radius:10px;
   width:900px;
  

}

.OneHourDrop
 {
 background-color:white;
 text-align:center;	
 width:150px;
 height:70px;
 z-index:1;
 opacity:0.1;
 border-color:black;
 border-width:4px;	
}

.OneHourDrop-Highlight
 {
 background-color:blue;
 text-align:center;	
 width:150px;
 height:70px;
 opacity:0.1;
 z-index:1;
 border-color:black;
 border-width:4px;
	
}



.OneHour
 {
 text-align:center;	
 width:150px;
 height:70px;
 background-color:white;
 opacity:0.1;
 z-index:1;
 border-color:black;
  border-width:4px;	
}

.OneHour-Highlight
 {
 text-align:center;	
 width:150px;
 height:70px;
 background-color:#33CCFF;
 opacity:0.1;
 z-index:1;
 border-color:black;
  border-width:4px;	
}

.draggables {
	
	width:120px; 
	 
	background-color: #C0C0C0;
        border-width:2px; 
	border-color:black; 
	border-style:solid;
	z-index:2;
	-moz-border-radius:10px;
   -khtml-border-radius:10px;
   opacity:0.8;
   -webkit-box-shadow: inset 0px 0px 91px #000000; /* webkit browser*/ -moz-box-shadow: inset 0px 0px 91px #000000;	/* firefox */ box-shadow: inset 0px 0px 91px #000000;
   }	


.Vorl {
	
	width:100px;
	position:relative;
	left:8px;
	top:-1px;
   z-index:3;
   	-moz-border-radius:5px;
   -khtml-border-radius:5px;

   
}

.Dozent {
	
	width:100px;
	position:relative;
	left:8px;
	top:-1px;
	z-index:3;
   -moz-border-radius:5px;
   -khtml-border-radius:5px;

	
}

	
.DropContainer {
	position:absolute; 
	top:50px;
	left:910px;
	right:140px; 
	border-width:2px; 
	border-color:black; 
	border-style:solid; 
	width:150px; 
	height:650px;
}



.DropContainer2 {
	position:absolute; 
	top:50px;
	left:1070px;
	right:140px; 
	border-width:2px; 
	border-color:black; 
	border-style:solid; 
	width:150px; 
	height:650px;
}

.Time {
	font-size:25px;
   font-family:Arial, Helvetica, sans-serif;
   
}


.timetableheader {
	
	 border-width:2px;
	  color:white;
	
}

.buttons {
	 -moz-border-radius:5px;
   -khtml-border-radius:5px;
   color:white;
   background-color:gray
	 
}

</style>


	  <script>
	$(function() {
	
		$( ".OneHourDrop" ).droppable({
			drop: function( event, ui ) {
				$( this ).removeClass('OneHourDrop').addClass('OneHourDrop-Highlight');   
		    }
		});
	});
	</script>
	
		  <script>
	$(function() {
	
		$( ".OneHour" ).droppable({
			drop: function( event, ui ) {
				$( this ).removeClass('OneHour').addClass('OneHour-Highlight');   
		    }
		});
	});
	</script>





</head>

<body background="img/Black_Background.jpg">


<div style="position:absolute; left:920px; top:50px; width:160px; height:800px;">
<table>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

</table>

</div>

<div style="position:absolute; left:1080px; top:50px; width:160px; height:800px;">
<table>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

<tr>
<td  id="droppable"  class="OneHourDrop"></td>
</tr>

</table>

</div>


<?php

$username = $_SESSION["username"];

//Anzahl der Draggables ermitteln

$verbindung = mysql_connect("rdbms.strato.de", "U1069521" , "doener") 
or die("Verbindung zur Datenbank konnte nicht hergestellt werden"); 
mysql_select_db("DB1069521") or die ("Datenbank konnte nicht ausgewählt werden"); 
 


$sql = "Select DraggablesAnzahl from user where username ='$username' ";

$res = mysql_query ($sql);

$dsatz = mysql_fetch_assoc($res);

$DraggablesAnzahl =$dsatz ["DraggablesAnzahl"];

echo "<br>";
echo "<br>";
echo "<br>";
echo "<br>";
echo $DraggablesAnzahl;
?>


<form style="position:absolute; top:0px; left:0px;" name="myform" id="myform" action="timetable-update.php" method="post">
<?php

//Formular zu Speicherung der neuen Position

for ($i=1;$i<=$DraggablesAnzahl;$i++)
{
echo"<input type='hidden' id='PositionTop".$i."'   name='PositionTop".$i."' value=''>";
echo"<input type='hidden' id='PositionLeft".$i."'  name='PositionLeft".$i."' value=''>";

}
?>



<?php

//Jquery Code erzeugen

for ($i=1;$i<=$DraggablesAnzahl;$i++)
{
echo"<script>";
echo"	$(function() {";
echo"  	          $( '#draggable".$i."' ).draggable({ ";	             
echo"	             stop: function(event, ui) { ";
	              
echo"	          var pos".$i." = ui.position;";
//echo"	          alert (pos".$i.".top+', '+pos".$i.".left);";

echo"             document.myform.PositionTop".$i.".value = pos".$i.".top;   ";
echo"             document.myform.PositionLeft".$i.".value = pos".$i.".left;   ";
       	       	          
	              	       	           	              
echo"	          }";	             

echo"            });";	                       		
echo"     });";          
echo"</script>";


//Werte aus Datenbank in Draggables

$verbindung = mysql_connect("rdbms.strato.de", "U1069521" , "doener") 
or die("Verbindung zur Datenbank konnte nicht hergestellt werden"); 
mysql_select_db("DB1069521") or die ("Datenbank konnte nicht ausgewählt werden"); 

$sql = "Select PositionTop$i, PositionLeft$i from user where username ='$username' ";

$res = mysql_query ($sql);

$dsatz = mysql_fetch_assoc($res);

$DBPositionTop =$dsatz ["PositionTop$i"];
$DBPositionLeft =$dsatz ["PositionLeft$i"];

/*
echo "Das ist Top: ".$DBPositionTop;
echo "Das ist Left: ".$DBPositionLeft;

echo"<br>";
echo"<br>";
*/

//Werte aus Datenbank in Draggables Ende


//Werte aus Datenbank in Eingabefelder

$verbindung = mysql_connect("rdbms.strato.de", "U1069521" , "doener") 
or die("Verbindung zur Datenbank konnte nicht hergestellt werden"); 
mysql_select_db("DB1069521") or die ("Datenbank konnte nicht ausgewählt werden"); 

$sql = "Select Vorl$i, Dozent$i from user where username ='$username' ";

$res = mysql_query ($sql);

$dsatz = mysql_fetch_assoc($res);

$DBVorl =$dsatz ["Vorl$i"];
$DBDozent=$dsatz ["Dozent$i"];

/*
echo "Das ist Vorl: ".$DBVorl;
echo "Das ist Dozent: ".$DBDozent;

echo"<br>";
echo"<br>";
*/

//Werte aus Datenbank in Eingabefelder Ende


//Divs fuer Draggables erzeugen


echo"<div style='top:". $DBPositionTop ." px; left: ". $DBPositionLeft ." px;' name='Div2' class='draggables' id='draggable".$i."'>";


echo"<input class='Vorl' name='Vorl".$i."' id='Vorl".$i."' value='".$DBVorl."' type='text' >";
echo"<input class='Dozent' name='Dozent".$i."' id='Dozent".$i."' value='".$DBDozent."' type='text' >";


/*
echo"<form name='myForm' id='myForm' action='deletedraggable.php' method='get'>";
echo"<input type='hidden' name='number' id='".$i."' value='".$i."'>";
echo"<a name='delete".$i."' id='delete".$i."' href='timetable.php?$i' onclick=''><img style=' position:absolute; top:2px; left:92%; width:10px; height:10px' src='X.png'></a>";
echo"</form>";
*/

echo"</div>";





}

?>

<input class="buttons" style=" position:absolute; top:0px; z-index:10" type="submit" name="Speichern" value="Speichern">

</form>



<div>
<table class="timetable" border="4">
<tr>
<th class="timetableheader">Uhrzeit</th>
<th class="timetableheader">Montag</th>
<th class="timetableheader">Dienstag</th>
<th class="timetableheader">Mittwoch</th>
<th class="timetableheader">Donnerstag</th>
<th class="timetableheader">Freitag</th>

</tr>

<tr>
<td id="droppable" class="OneHour"><font class="Time"> 8:00-8:45</font></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>

</tr>

<tr>
<td class="OneHour"><font class="Time"> 8:40-9:30</font></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>

</tr>

<tr>
<td class="OneHour"><font class="Time"> 9:45-11:15</font></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>

</tr>

<tr>
<td class="OneHour"><font class="Time"> 11:30-12:15</font></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>

</tr>

<tr>
<td class="OneHour"><font class="Time"> 12:15-13:00</font></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>

</tr>

<tr>
<td class="OneHour"><font class="Time"> 13:30-14:15</font></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>

</tr>

<tr>
<td class="OneHour"><font class="Time"> 14:15-15:00</font></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>

</tr>

<tr>
<td class="OneHour"><font class="Time"> 15:15-16:00</font></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>

</tr>

<tr>
<td class="OneHour"><font class="Time"> 16:00-16:45</font></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>
<td class="OneHour"></td>

</tr>

</table>
</div>




<div style="position:absolute; top:550px" id="dragpos"></div>


<form style="position:absolute; top:0px; left:90px;" action="logout.php" method="post">
<input class="buttons" type="submit" value="Logout">
</form>

<form style="position:absolute; top:0px; left:160px;" action="create_draggable.php" method="post">
<input type="hidden" name="NeuesFach" value="Neues Fach">

<input class="buttons" type="submit" value="Neues Fach">
</form>

<form style="position:absolute; top:0px; left:260px;" action="delete_draggable.php" method="post">
<input type="hidden" name="FachL" value="FachL">

<input class="buttons" type="submit" value="Fach L&ouml;schen">
</form>




</body>

</html>
